import java.util.Arrays;
import java.util.Scanner;
public class demo1 {
    public static void main(String[] args) {
        Scanner scanner=new Scanner(System.in);
        int N=scanner.nextInt();
        int []sum=new int[10000];
            int ret=0;
            while (scanner.hasNext()) {
                sum[ret++] = scanner.nextInt();
            }

        int m=0;
        int n=0;
        Arrays.sort(sum,0,ret);
        for(int i=0;i<ret;i++){
            if(i<ret-1&&sum[i]==sum[i+1]){
                n=sum[i];
            }
            if(sum[i+1]-sum[i]>1){
                m=sum[i]+1;
            }
        }
        System.out.println(m+" "+n);

    }
}

